package cn.oa.service.impl;

import cn.oa.dao.DepartmentDao;
import cn.oa.entity.Department;
import cn.oa.service.DepartmentService;
import cn.oa.util.SessionFatoryUtil;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.sql.SQLException;
import java.util.List;

/**
 * @Description TODO
 * @Author hyl
 * @Date 2022/3/29 9:06
 **/
@Service("departmentService")

public class DepartmentServiceImpl implements DepartmentService {
	@Autowired
	private DepartmentDao departmentDao ;//= sqlSession.getMapper(DepartmentDao.class);
	@Override
	public List<Department> getAllDepartments() throws SQLException {
		//SqlSession sqlSession = SessionFatoryUtil.getSqlSession();

		//DepartmentDao departmentDao = sqlSession.getMapper(DepartmentDao.class);
		List<Department> list = departmentDao.getAllDepartments();

		//SessionFatoryUtil.closeSqlSession(sqlSession);
		return list;
	}

	public void setDepartmentDao(DepartmentDao departmentDao) {
		this.departmentDao = departmentDao;
	}
}
